Hide oauth providers which are not configured

Dominik Sander 10 年之前
父节点
当前提交
fe192e8ca5
共有 2 个文件被更改,包括 14 次插入3 次删除
  1. 5 0
      app/helpers/service_helper.rb
  2. 9 3
      app/views/services/index.html.erb

+ 5 - 0
app/helpers/service_helper.rb

@@ -0,0 +1,5 @@
1
+module ServiceHelper
2
+  def has_oauth_configuration_for(provider)
3
+    ENV["#{provider.upcase}_OAUTH_KEY"].present? && ENV["#{provider.upcase}_OAUTH_SECRET"].present?
4
+  end
5
+end

+ 9 - 3
app/views/services/index.html.erb

@@ -11,9 +11,15 @@
11 11
         <%= link_to 'wiki', 'https://github.com/cantino/huginn/wiki/Configuring-OAuth-applications', target: :_blank %>
12 12
         for guidance.
13 13
       </p>
14
-      <p><%= link_to "Authenticate with Twitter", "/auth/twitter" %></p>
15
-      <p><%= link_to "Authenticate with 37Signals (Basecamp)", "/auth/37signals" %></p>
16
-      <p><%= link_to "Authenticate with Github", "/auth/github" %></p>
14
+      <% if has_oauth_configuration_for('twitter') %>
15
+        <p><%= link_to "Authenticate with Twitter", "/auth/twitter" %></p>
16
+      <% end %>
17
+      <% if has_oauth_configuration_for('thirty_seven_signals') %>
18
+        <p><%= link_to "Authenticate with 37Signals (Basecamp)", "/auth/37signals" %></p>
19
+      <% end -%>
20
+      <% if has_oauth_configuration_for('github') %>
21
+        <p><%= link_to "Authenticate with Github", "/auth/github" %></p>
22
+      <% end -%>
17 23
       <hr>
18 24
 
19 25
       <div class='table-responsive'>